package com.huadao.cart_ccs.common;

import android.content.Context;
import android.widget.TextView;

import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import com.huadao.cart_ccs.R;

public class TemperatureMarkerView extends MarkerView {
    private TextView tvContent;
    private TextView tvContent_Time;

    /**
     * Constructor. Sets up the MarkerView with a custom layout resource.
     *
     * @param context
     * @param layoutResource the layout resource to use for the MarkerView
     */
    public TemperatureMarkerView(Context context, int layoutResource) {
        super(context, layoutResource);
        tvContent = findViewById(R.id.tvContent);
        tvContent_Time= findViewById(R.id.tvContent_Time);
    }

    @Override
    public void refreshContent(Entry e, Highlight highlight) {
        String t=UtilHelpers.getTime(e.getX());
        tvContent_Time.setText(t);
        tvContent.setText(String.valueOf(e.getY()));
        super.refreshContent(e, highlight);
    }

    @Override
    public MPPointF getOffset() {
        MPPointF mpPointF=super.getOffset();
        mpPointF.x=-(getWidth() / 2);
        mpPointF.y=-getHeight();
        return mpPointF;
    }

}
